package net.zoneland.zrdp.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 读取项目相关配置
 *
 * @author zonevue
 */
@Component
@ConfigurationProperties(prefix = "zonevue")
public class ZonevueConfig
{
    /** 项目名称 */
    private String name;

    /** 版本 */
    private String version;

    /** 版权年份 */
    private String copyrightYear;

    /** 实例演示开关 */
    private boolean demoEnabled;

    /** 上传路径 */
    private static String profile;

    /** 获取地址开关 */
    private static boolean addressEnabled;

    /** 验证码类型 */
    private static String captchaType;

    /** 登陆解密用 secretKey */
    private String secretKey;

    /** 登陆解密用 iv */
    private String iv;

    /** redis key 前缀  */
    private String redisPrefix;

    /** 是否开启浙江移动sso认证 */
    private boolean ssoEnabled;

    /** 浙江移动sso认证的访问地址 */
    private String ssoUrl;

    /** 浙江移动获取用户信息的接口地址 */
    private String ssoWebLoginedUserUrl;

    public String getSsoWebLoginedUserUrl() {
        return ssoWebLoginedUserUrl;
    }
    @Value("${zonevue.sso.ssoWebLoginedUserUrl}")
    public void setSsoWebLoginedUserUrl(String ssoWebLoginedUserUrl) {
        this.ssoWebLoginedUserUrl = ssoWebLoginedUserUrl;
    }

    public boolean isSsoEnabled() {
        return ssoEnabled;
    }

    @Value("${zonevue.sso.enabled:false}")
    public void setSsoEnabled(boolean ssoEnabled) {
        this.ssoEnabled = ssoEnabled;
    }

    public String getSsoUrl() {
        return ssoUrl;
    }

    @Value("${zonevue.sso.ssoUrl}")
    public void setSsoUrl(String ssoUrl) {
        this.ssoUrl = ssoUrl;
    }

    public String getRedisPrefix() {
        return redisPrefix;
    }

    public void setRedisPrefix(String redisPrefix) {
        this.redisPrefix = redisPrefix;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getIv() {
        return iv;
    }

    public void setIv(String iv) {
        this.iv = iv;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getVersion()
    {
        return version;
    }

    public void setVersion(String version)
    {
        this.version = version;
    }

    public String getCopyrightYear()
    {
        return copyrightYear;
    }

    public void setCopyrightYear(String copyrightYear)
    {
        this.copyrightYear = copyrightYear;
    }

    public boolean isDemoEnabled()
    {
        return demoEnabled;
    }

    public void setDemoEnabled(boolean demoEnabled)
    {
        this.demoEnabled = demoEnabled;
    }

    public static String getProfile()
    {
        return profile;
    }

    public void setProfile(String profile)
    {
        ZonevueConfig.profile = profile;
    }

    public static boolean isAddressEnabled()
    {
        return addressEnabled;
    }

    public void setAddressEnabled(boolean addressEnabled)
    {
        ZonevueConfig.addressEnabled = addressEnabled;
    }

    public static String getCaptchaType() {
        return captchaType;
    }

    public void setCaptchaType(String captchaType) {
        ZonevueConfig.captchaType = captchaType;
    }

    /**
     * 获取导入上传路径
     */
    public static String getImportPath()
    {
        return getProfile() + "/import/";
    }

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath()
    {
        return getProfile() + "/avatar/";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath()
    {
        return getProfile() + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath()
    {
        return getProfile() + "/upload/";
    }

    /**
     * 代码文件生成路径
     */
    public static String getGenPath()
    {
        return getProfile() + "/gen/";
    }

}
